import * as React from 'react';
import { NodeType } from '../../reducer/const';

import TaskNode from './TaskNode';
import BranchNode from './BranchNode';
import MegerNode from './MegerNode';
import ConditionNode from './ConditionNode';
import SyncNode from './SyncNode';
import StartNode from './StartNode';
import CompleteNode from './CompleteNode';
import EndNode from './EndNode';
import ErrorNode from './ErrorNode';


export default class NodeAdapter extends React.Component<any, any> {

    constructor(props: any) {
        super(props);
        this.state = { ...this.props };
    }

    render() {
        const {type} = this.state;
        switch (type) {
            case NodeType.StartNode:
                return <StartNode {...this.props} />;
            case NodeType.CompleteNode: ;
                return <CompleteNode {...this.props} />;
            case NodeType.EndNode: ;
                return <EndNode {...this.props} />;
            case NodeType.ErrorNode:
                return <ErrorNode {...this.props} />;
            case NodeType.BranchNode: ;
                return <BranchNode {...this.props} />;
            case NodeType.MegerNode: ;
                return <MegerNode {...this.props} />;
            case NodeType.ConditionNode:
                return <ConditionNode {...this.props} />;
            case NodeType.SyncNode:
                return <SyncNode {...this.props} />;
            default:
                return <TaskNode {...this.props} />;
        }
    }
}
